home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / PowerMacOberon feb96 / Debugger / Debug.Mod (.txt) < prev    next >
Encoding:
Oberon Text  |  1995-09-01  |  22.5 KB  |  601 lines  |  [TEXT/.Ob4]

  1. Syntax10.Scn.Fnt
  2. StampElems
  3. Alloc
  4. 1 Sep 95
  5. InfoElems
  6. Alloc
  7. Syntax10.Scn.Fnt
  8. StampElems
  9. Alloc
  10. 1 Sep 95
  11. "Title": Run time debugger
  12. "Author": mah
  13. "Abstract": command module
  14. "Keywords": 
  15. "Version": 
  16. "From":  25.10.94 16:53:38
  17. "Until": 
  18. "Changes": 
  19. ParcElems
  20. Alloc
  21. Syntax10i.Scn.Fnt
  22. FoldElems
  23. Syntax10.Scn.Fnt
  24. Syntax10i.Scn.Fnt
  25.         mod: Modules.Module;            (* current module *)
  26.         pc: LONGINT;                    (* current pc *)
  27.     END;
  28. Syntax10.Scn.Fnt
  29.     END;
  30. Syntax10.Scn.Fnt
  31. Syntax10i.Scn.Fnt
  32.         pos: LONGINT;                    (* new position in text of PC *)
  33.         name: ARRAY 32 OF CHAR;        (* name of file of module *)
  34.         done: BOOLEAN;                (* TRUE -> pc somewhere set *)
  35.     END;
  36. Syntax10.Scn.Fnt
  37.         base: LONGINT;
  38.         syms: RTDC.Sym;
  39.         regs: Sys.ExceptionInfo;
  40.         modName: ARRAY 32 OF CHAR;
  41.     END;
  42. Syntax10.Scn.Fnt
  43.     mf: TextFrames.Frame;
  44.     v: Viewers.Viewer;
  45.     x, y: INTEGER;
  46. BEGIN
  47.     mf := TextFrames.NewMenu(title,menu);
  48.     TextFrames.Open(f, f.text, 0);
  49.     IF handle # NIL THEN f.handle := handle END;
  50.     IF userTrack THEN Oberon.AllocateUserViewer(0, x, y)
  51.     ELSE Oberon.AllocateSystemViewer(0, x, y) END;
  52.     v := MenuViewers.New(mf, f, TextFrames.menuH, x, y)
  53. END Browse;
  54. Syntax10.Scn.Fnt
  55. VAR win: ARRAY 3 OF CHAR; level: INTEGER;
  56. BEGIN
  57.     level := 1; Texts.Read (s, win[0]); Texts.Read (s, win[1]); win[2] := 0X;
  58.     REPEAT
  59.         IF win = "(*" THEN INC (level)
  60.         ELSIF win = "*)" THEN DEC (level) END;
  61.         win[0] := win[1]; Texts.Read (s, win[1])
  62.     UNTIL level = 0
  63. END SkipComment;
  64. Syntax10.Scn.Fnt
  65. VAR found : BOOLEAN;
  66. BEGIN
  67.     REPEAT
  68.         Texts.Scan (s);
  69.         found := TRUE;
  70.         WHILE (s.class=Texts.Char) & (s.c=CHR (28)) DO found := FALSE; Texts.Scan (s) END;    (* skip text elements *)
  71.         IF (s.class=Texts.Char) & (s.c='(') THEN 
  72.             Texts.Scan (s);
  73.             IF (s.class=Texts.Char) & (s.c='*') THEN found := FALSE; SkipComment (s) ELSE RETURN END
  74.         END
  75.     UNTIL found;
  76. END Token;
  77. Syntax10.Scn.Fnt
  78. VAR s: Texts.Scanner; set: SET; a: ARRAY 32 OF CHAR;
  79. BEGIN
  80.     Texts.OpenScanner (s, t, pos);
  81.     REPEAT Token (s) UNTIL (s.class#Texts.Char) OR (s.c#';');        
  82.     IF s.class # Texts.Name THEN RETURN END;
  83.     IF ((s.s = "END") OR (s.s = "ELSE") OR (s.s = "ELSIF")) THEN pos := Texts.Pos (s)-1 END
  84. END NextToken;
  85. Syntax10.Scn.Fnt
  86.     VAR p: TextFrames.Parc; beg: LONGINT;
  87. BEGIN
  88.     IF f = NIL THEN
  89.         IF fnt = NIL THEN dsr := 0 ELSE dsr := - fnt.minY END
  90.     ELSE
  91.         TextFrames.ParcBefore(f(TextFrames.Frame).text, pos, p, beg);
  92.         dsr := SHORT(p.dsr DIV TextFrames.Unit)
  93. END GetDsr;
  94. Syntax10.Scn.Fnt
  95. VAR end, delta: LONGINT;
  96. BEGIN
  97.     delta := 200;
  98.     LOOP end := TextFrames.Pos(f, f.X + f.W, f.Y);
  99.         IF (f.org <= pos) & (pos < end) OR (f.org = end) THEN EXIT END;
  100.         TextFrames.Show (f, pos - delta); DEC(delta, 20)
  101. END Show;
  102. Syntax10.Scn.Fnt
  103. VAR dsr: INTEGER; new: PCElem;
  104. BEGIN
  105.     WITH e: PCElem DO
  106.         WITH msg : TextFrames.DisplayMsg DO
  107.             IF ~ msg.prepare THEN
  108.                 GetDsr (msg.frame, msg.pos, msg.fnt, dsr);
  109.                 Display.CopyPattern(Display.white, iconPC, msg.X0, msg.Y0 + dsr, Display.paint)
  110.             END
  111.         |    msg : Texts.CopyMsg DO
  112.             NEW (new); Texts.CopyElem (e, new); msg.e := new
  113.         ELSE
  114.         END
  115. END PCElemHandle;
  116. Syntax10.Scn.Fnt
  117. VAR dsr: INTEGER; new: BPElem;
  118. BEGIN
  119.     WITH e: BPElem DO
  120.         WITH msg : TextFrames.DisplayMsg DO
  121.             IF ~ msg.prepare THEN
  122.                 GetDsr (msg.frame, msg.pos, msg.fnt, dsr);
  123.                 Display.CopyPattern(Display.white, iconBP, msg.X0, msg.Y0 + dsr, Display.paint)
  124.             END
  125.         |    msg : Texts.CopyMsg DO
  126.             NEW (new); Texts.CopyElem(e, new); msg.e := new
  127.         ELSE
  128.         END
  129. END BPElemHandle;
  130. Syntax10.Scn.Fnt
  131. VAR new: PCElem;
  132. BEGIN
  133.     NEW (new); new.handle := PCElemHandle;
  134.     new.W := 13 * TextFrames.Unit; new.H := 9 * TextFrames.Unit;
  135.     new.mod := mod; new.pc := pc;
  136.     RETURN new
  137. END AllocPCElem;
  138. Syntax10.Scn.Fnt
  139. VAR text: Texts.Text; beg, end, time: LONGINT;
  140. BEGIN 
  141.     Texts.OpenScanner(s, Oberon.Par.text, Oberon.Par.pos); Texts.Scan (s);
  142.     IF ((s.class = Texts.Char) & (s.c = "^")) OR (Oberon.Par.frame = Oberon.Par.vwr.dsc) THEN 
  143.         Oberon.GetSelection(text, beg, end, time);
  144.         IF time >= 0 THEN Texts.OpenScanner(s, text, beg); Texts.Scan(s) END;
  145.         Oberon.Par.text := text;
  146.         Oberon.Par.pos := Texts.Pos (s)
  147.     ELSE Oberon.Par.pos := Texts.Pos (s) END
  148. END GetArg;
  149. Syntax10.Scn.Fnt
  150. VAR v: Viewers.Viewer; s: Texts.Scanner; r: Texts.Reader; pos, startPos: LONGINT; newpc: PCElem; i: INTEGER;
  151. BEGIN
  152.     WITH f: TextFrames.Frame DO
  153.         WITH msg: SetPCMsg DO
  154.             startPos := msg.pos; pos := startPos; Texts.OpenReader (r, f.text, 0); Texts.ReadElem(r);
  155.             WHILE ~ r.eot & ~ (r.elem IS PCElem) DO
  156.                 IF r.elem IS BPElem THEN INC (msg.pos) END;
  157.                 Texts.ReadElem (r)
  158.             END;
  159.             IF ~ r.eot THEN pos := Texts.ElemPos (r.elem); Texts.Delete (f.text, pos, pos+1) END;
  160.             v := Viewers.This (f.X, f.Y);
  161.             Texts.OpenScanner(s, v.dsc(TextFrames.Frame).text, 0); Texts.Scan(s);
  162.             IF (msg.name = s.s) & (startPos >= 0) THEN
  163.                 newpc := AllocPCElem (Modules.ThisMod (msg.name), RTDT.PC ());
  164.                 Texts.WriteElem (w, newpc);
  165.                 NextToken (f.text, msg.pos);
  166.                 Texts.Insert (f.text, msg.pos, w.buf);
  167.                 Show (f, msg.pos + 1);
  168.                 lastPos := pos; lastBeginPC := RTDT.procs.beginPC; msg.done := TRUE
  169.             END
  170.         | msg: RTDB.GetBPMsg DO
  171.             Texts.OpenReader (r, f.text, 0); Texts.ReadElem (r);
  172.             WHILE ~ r.eot DO
  173.                 IF r.elem IS BPElem THEN
  174.                     v := Viewers.This (f.X, f.Y);
  175.                     Texts.OpenScanner(s, v.dsc(TextFrames.Frame).text, 0); Texts.Scan(s);
  176.                     i := 0; WHILE (s.s[i] # 0X) & (s.s[i] # '.') DO INC (i) END; s.s[i] := 0X;
  177.                     IF ~ RTDB.BreakAtPC (s.s, Texts.ElemPos (r.elem)) THEN
  178.                         Texts.WriteString (w, s.s); Texts.WriteString (w, ": Illegal breakpoint pos ");
  179.                         Texts.WriteInt (w, Texts.ElemPos (r.elem), 0); Texts.WriteLn (w);
  180.                         Texts.Append (Oberon.Log, w.buf)
  181.                     END
  182.                 END;
  183.                 Texts.ReadElem (r)
  184.             END
  185.         ELSE PrevFrameHandle (f, msg) END
  186. END FrameHandle;
  187. Syntax10.Scn.Fnt
  188. VAR p: RTDT.Proc;
  189. BEGIN
  190.     p := RTDT.procs;
  191.     WHILE p # NIL DO
  192.         Texts.WriteString (w, p.modName); Texts.Write (w, '.'); Texts.WriteString (w, p.name);
  193.         Texts.WriteLn (w);
  194.         p := p.up
  195. END WriteStackText;
  196. Syntax10.Scn.Fnt
  197. VAR t: Text; mod: Modules.Module; ok: BOOLEAN; p: RTDT.Proc; org: LONGINT;
  198. BEGIN
  199.     WITH f: TextFrames.Frame DO
  200.         WITH msg: SetPCMsg DO
  201.             IF RTDT.procs.regs # latestRTDTprocs.regs THEN
  202.                 latestRTDTprocs := RTDT.procs;
  203.                 WriteStackText;
  204.                 Texts.Delete (f.text, 0, f.text.len);
  205.                 Texts.Append (f.text, w.buf)
  206.             END
  207.         ELSE TextFrames.Handle (f, msg)
  208.         END
  209. END StackHandle;
  210. Syntax10.Scn.Fnt
  211. Syntax10i.Scn.Fnt
  212. VAR msg: SetPCMsg; x, y, i: INTEGER; v: Viewers.Viewer; f, f2: TextFrames.Frame; t: Texts.Text; pc: LONGINT;
  213. BEGIN
  214.     pc := RTDT.PC (); RTDB.PCToPos (pc, msg.name, msg.pos);
  215.     IF ~RTDT.Debugging () THEN msg.pos := -1 END;
  216.     i := 0; WHILE msg.name[i] # 0X DO INC (i) END;
  217.     msg.name[i] := '.'; msg.name[i+1] := 'M'; msg.name[i+2] := 'o'; msg.name[i+3] := 'd'; msg.name[i+4] := CHR(0);
  218.     msg.done := FALSE;
  219.     Viewers.Broadcast (msg);
  220.     IF ~msg.done & RTDT.Debugging () THEN                         (* text not shown -> open a new one *)
  221.         Oberon.AllocateUserViewer (0, x, y);
  222.         t := TextFrames.Text (msg.name);
  223.         FoldElems.ExpandAll (t, 0, TRUE);
  224.         v := MenuViewers.New (TextFrames.NewMenu (msg.name, "^Edit.Menu.Text"),
  225.             TextFrames.NewText (t, msg.pos-100), TextFrames.menuH, x, y);
  226.         v.handle (v, msg);
  227. END PCHandler;
  228. Syntax10.Scn.Fnt
  229. VAR msg: SetPCMsg;
  230. BEGIN msg.pos := -1; Viewers.Broadcast (msg)
  231. END PCOffHandler;
  232. Syntax10.Scn.Fnt
  233. VAR t: Text;
  234. BEGIN
  235.     NEW (t); Texts.Open (t, ""); t.notify := TextFrames.NotifyDisplay;
  236.     t.base := base; t.syms := syms; t.regs := regs; COPY (modName, t.modName);
  237.     RETURN t
  238. END NewText;
  239. Syntax10.Scn.Fnt
  240. VAR msg: UpdateDataMsg;
  241. BEGIN Viewers.Broadcast (msg)
  242. END DataHandler;
  243. Syntax10b.Scn.Fnt
  244. Syntax10.Scn.Fnt
  245. VAR dummy: ARRAY RTDT.StackSize OF LONGINT;
  246. BEGIN IF RTDT.Debugging () THEN RTDB.StepAll; HALT (RTDT.EnterDebugMode) END
  247. END StepInto;
  248. Syntax10.Scn.Fnt
  249. VAR dummy: ARRAY RTDT.StackSize OF LONGINT;
  250. BEGIN IF RTDT.Debugging () THEN RTDB.StepOverAll; HALT (RTDT.EnterDebugMode) END
  251. END Step;
  252. Syntax10.Scn.Fnt
  253. VAR dummy: ARRAY RTDT.StackSize OF LONGINT;
  254. BEGIN IF RTDT.Debugging () THEN RTDT.PopProc; RTDB.StepOverAll; HALT (RTDT.EnterDebugMode) END
  255. END Return;
  256. Syntax10.Scn.Fnt
  257. VAR dummy: ARRAY RTDT.StackSize OF LONGINT;
  258. BEGIN IF RTDT.Debugging () THEN RTDB.BreakAll; HALT (RTDT.EnterDebugMode) END
  259. END Run;
  260. Syntax10.Scn.Fnt
  261. BEGIN RTDT.Install
  262. END PostMortem;
  263. Syntax10.Scn.Fnt
  264. BEGIN
  265.     lastPos := 0; lastBeginPC := 0;
  266.     RTDB.CleanUp;
  267.     RTDT.Stop
  268. END Close;
  269. Syntax10.Scn.Fnt
  270. VAR s: Texts.Scanner;
  271. BEGIN
  272.     IF RTDT.Debugging () OR RTDT.Launching () THEN Close END;
  273.     GetArg (s); RTDB.AddModules (s);
  274.     RTDT.Install; RTDT.Prepare;
  275.     RTDB.EntryAll
  276. END Trace;
  277. Syntax10.Scn.Fnt
  278. VAR m: RTDB.ModuleInfo;
  279. BEGIN
  280.     m := RTDB.modules;
  281.     WHILE m # NIL DO Texts.WriteString (w, m.name); Texts.WriteLn (w); m := m.next END;
  282.     Texts.Append (Oberon.Log, w.buf)
  283. END ShowModules;
  284. Syntax10.Scn.Fnt
  285. VAR v: Viewers.Viewer; x, y: INTEGER; p: RTDT.Proc; t: Texts.Text; f: TextFrames.Frame;
  286. BEGIN
  287.     WriteStackText;
  288.     latestRTDTprocs := RTDT.procs;
  289.     t := TextFrames.Text (""); Texts.Append (t, w.buf);
  290.     f := TextFrames.NewText (t, 0);
  291.     f.handle := StackHandle;
  292.     Oberon.AllocateSystemViewer (0, x, y);
  293.     v := MenuViewers.New (TextFrames.NewMenu ("Debug.Stack", InfoMenu), f, TextFrames.menuH, x, y)    
  294. END Stack;
  295. Syntax10.Scn.Fnt
  296.     proc: RTDT.Proc;
  297.     i, off, x, y: INTEGER;
  298.     name, modName, procName: ARRAY 64 OF CHAR;
  299.     s: Texts.Scanner;
  300.     pos: LONGINT;
  301.     t: Texts.Text;
  302.     v: Viewers.Viewer;
  303. BEGIN
  304.     GetArg (s); 
  305.     IF s.class # Texts.Name THEN RETURN END;
  306.     COPY (s.s, name); i := 0;
  307.     WHILE (name[i] # '.') & (name[i] # CHR (0)) DO modName[i] := name[i]; INC (i) END;
  308.     modName[i] := CHR (0);
  309.     IF name[i] = '.' THEN
  310.         off:=0; INC (i);
  311.         WHILE name[i+off] # CHR (0) DO procName[off] := name[i + off]; INC (off) END; procName[off] := CHR (0);
  312.         proc := RTDT.procs;
  313.         WHILE (proc # NIL) & ((proc.name # procName) OR (proc.modName # modName)) DO proc := proc.up END;
  314.         IF proc # NIL THEN
  315.             RTDB.PCToPos (proc.pc, name, pos);
  316.             i := 0; WHILE modName[i] # 0X DO INC (i) END;
  317.             modName[i] := '.'; modName[i+1] := 'M'; modName[i+2] := 'o'; modName[i+3] := 'd'; modName[i+4] := CHR(0);
  318.             Oberon.AllocateUserViewer (0, x, y);
  319.             t := TextFrames.Text (modName);
  320.             FoldElems.ExpandAll (t, 0, TRUE);
  321.             v := MenuViewers.New (TextFrames.NewMenu (modName, "^Edit.Menu.Text"),
  322.                 TextFrames.NewText (t, pos-100), TextFrames.menuH, x, y);
  323.             TextFrames.SetCaret (v.dsc.next(TextFrames.Frame), pos)    
  324.         END
  325. END Source;
  326. Syntax10.Scn.Fnt
  327. VAR e: BPElem; m: TextFrames.InsertElemMsg; f: Display.Frame; h: Display.Handler; 
  328. BEGIN
  329.     NEW (e); m.e := e;
  330.     e.W := 13 * TextFrames.Unit; e.H := 9 * TextFrames.Unit;
  331.     e.handle := BPElemHandle;
  332.     Oberon.FocusViewer.handle(Oberon.FocusViewer, m)
  333. END Breakpoint;
  334. Syntax10.Scn.Fnt
  335. Syntax10i.Scn.Fnt
  336.     i, off, x, y: INTEGER;
  337.     name, modName, procName: ARRAY 64 OF CHAR;
  338.     s: Texts.Scanner;
  339.     mod: Modules.Module;
  340.     v: Viewers.Viewer;
  341.     f: TextFrames.Frame;
  342.     syms: RTDC.Sym;
  343.     proc: RTDT.Proc;
  344.     t: Text;
  345. BEGIN
  346.     GetArg (s); 
  347.     IF s.class # Texts.Name THEN RETURN END;
  348.     COPY (s.s, name); i := 0;
  349.     WHILE (name[i] # '.') & (name[i] # CHR (0)) DO modName[i] := name[i]; INC (i) END;
  350.     modName[i] := CHR (0);
  351.     IF name[i]#'.' THEN 
  352.         RTDC.Symbols (modName, syms);
  353.         IF syms = NIL THEN
  354.             Texts.WriteString (w, modName); Texts.WriteString (w, " not compilable");
  355.             Texts.WriteLn (w); Texts.Append (Oberon.Log, w.buf);
  356.             RETURN
  357.         END;
  358.         mod := Modules.ThisMod (modName);
  359.         RTDD.GetScope (w, NIL, syms, mod.SB, 0);
  360.         t := NewText (syms, mod.SB, NIL, modName)
  361.     ELSE                                    (* procedure *)
  362.         off:=0; INC (i);
  363.         WHILE name[i+off] # CHR (0) DO procName[off] := name[i + off]; INC (off) END; procName[off] := CHR (0);
  364.         proc := RTDT.procs;
  365.         WHILE (proc # NIL) & ((proc.name # procName) OR (proc.modName # modName)) DO proc := proc.up END;
  366.         IF proc = NIL THEN
  367.             Texts.WriteString (w, name); Texts.WriteString (w, " not on stack"); 
  368.             Texts.WriteLn (w); Texts.Append (Oberon.Log, w.buf);
  369.             RETURN
  370.         END;
  371.         syms := RTDC.FindProc (proc);
  372.         RTDD.GetLocalScope (w, NIL, syms, proc.regs, 0);
  373.         t := NewText (syms, 0, proc.regs, modName)
  374.     END;
  375.     Oberon.AllocateSystemViewer (0, x, y);
  376.     f := TextFrames.NewText (t, 0);
  377.     Texts.Append (f.text, w.buf);
  378.     v := MenuViewers.New (TextFrames.NewMenu (name, "^Edit.Menu.Text"), f, TextFrames.menuH, x, y)
  379. END Data;
  380. Syntax10.Scn.Fnt
  381.     name : ARRAY 66 OF CHAR;
  382.     f: TextFrames.Frame;
  383.     syms: RTDC.Sym;
  384.     t: Text;
  385.     i, j: INTEGER;
  386. BEGIN
  387.     IF RTDT.procs = NIL THEN RETURN END;
  388.     name := "@";
  389.     syms := RTDC.FindProc (RTDT.procs);
  390.     RTDD.GetLocalScope (w, NIL, syms, RTDT.procs.regs, 0);
  391.     t := NewText (syms, 0, RTDT.procs.regs, name);
  392.     Texts.WriteLn (w); Texts.Append (t, w.buf);
  393.     i := 0;
  394.     WHILE RTDT.procs.modName[i] # 0X DO name[i] := RTDT.procs.modName[i]; INC (i) END;
  395.     name[i] := '.'; INC (i); j := 0;
  396.     WHILE RTDT.procs.name[j] # 0X DO name[i] := RTDT.procs.name[j]; INC (j); INC (i) END;
  397.     name[i] := 0X; 
  398.     f := TextFrames.NewText (t, 0);
  399.     Texts.Append (f.text, w.buf);
  400.     Browse(f, FALSE, NIL, "Locals", "^Edit.Menu.Text")
  401. END Locals;
  402. Syntax10.Scn.Fnt
  403.     mod: Modules.Module;
  404.     name : ARRAY 32 OF CHAR;
  405.     f: TextFrames.Frame;
  406.     syms: RTDC.Sym;
  407.     t: Text;
  408.     i: INTEGER;
  409. BEGIN
  410.     IF RTDT.procs # NIL THEN
  411.         RTDC.Symbols (RTDT.procs.modName, syms);
  412.         IF syms = NIL THEN
  413.             Texts.WriteString (w, RTDT.procs.modName); Texts.WriteString (w, " has no variables");
  414.             Texts.WriteLn (w); Texts.Append (Oberon.Log, w.buf);
  415.             RETURN
  416.         END;
  417.         mod := Modules.ThisMod (RTDT.procs.modName);
  418.         name := "@";
  419.         RTDD.GetScope (w, NIL, syms, mod.SB, 0);
  420.         t := NewText (syms, mod.SB, NIL, name)
  421.     END;
  422.     Texts.WriteLn (w); Texts.Append (t, w.buf);
  423.     f := TextFrames.NewText (t, 0);
  424.     Texts.Append (f.text, w.buf);
  425.     Browse(f, FALSE, NIL, "Globals", "^Edit.Menu.Text");
  426. END Globals;
  427. Syntax10.Scn.Fnt
  428.     VAR line: ARRAY 10 OF SET;
  429. BEGIN
  430.     line[1] := {3..9};
  431.     line[2] := {1..11};
  432.     line[3] := {0, 1, 3..7, 11, 12};
  433.     line[4] := {0, 1, 3..6, 8..12};
  434.     line[5] := {0, 1, 5, 6, 8..12};
  435.     line[6] := {0, 1, 3, 4, 6, 8..12};
  436.     line[7] := {0, 1, 5..7, 11, 12};
  437.     line[8] := {1..11};
  438.     line[9] := {3..9};
  439.     iconPC := Display.NewPattern(line, 13, 9);
  440.     line[1] := {3..9};
  441.     line[2] := {1..11};
  442.     line[3] := {0, 1, 5, 6, 8..12};
  443.     line[4] := {0, 1, 3, 4, 6, 8..12};
  444.     line[5] := {0, 1, 5, 6, 10..12};
  445.     line[6] := {0, 1, 3, 4, 6, 8, 9, 11, 12};
  446.     line[7] := {0, 1, 5, 6, 10..12};
  447.     line[8] := {1..11};
  448.     line[9] := {3..9};
  449.     iconBP := Display.NewPattern(line, 13, 9);
  450. END InitIcon;
  451. Syntax10.Scn.Fnt
  452. Syntax10i.Scn.Fnt
  453.     Texts.OpenWriter (w); 
  454.     InitIcon;
  455.     RTDT.debugQ.Add (PCHandler);
  456.     RTDT.debugQ.Add (DataHandler);
  457.     RTDT.startQ.Add (PCOffHandler);
  458.     HandlerElems.ResetHandlers;                    (******************  only temporary *******)
  459.     NEW (latestRTDTprocs); (* dummy to prevent trap when stack viewer opened before first step *)
  460.     HandlerElems.SetHandler ("PC control", FrameHandle, PrevFrameHandle);
  461.     HandlerElems.SetHandler ("Data control", DataHandle, PrevDataHandle);
  462.     Texts.WriteString (w, "Debugger mah 11.4.95"); Texts.WriteLn (w); Texts.Append (Oberon.Log, w.buf)
  463. Syntax10.Scn.Fnt
  464.     name: ARRAY 32 OF CHAR;
  465.     i, j: INTEGER;
  466.     mod: Modules.Module;
  467.     cmd: Modules.Command;
  468.     s: Texts.Scanner;
  469.     sb, pc: LONGINT;
  470. BEGIN
  471.     IF ~RTDT.Debugging () THEN
  472.         GetArg (s); 
  473.         IF s.class = Texts.Name THEN
  474.             COPY (s.s, name);
  475.             i := 0; j := 0;
  476.             WHILE name[j] # 0X DO 
  477.                 IF name[j] = "." THEN i := j END;
  478.                 INC(j)
  479.             END;
  480.             IF i > 0 THEN
  481.                 name[i] := 0X;    
  482.                 mod := Modules.ThisMod (name);
  483.                 IF mod # NIL THEN
  484.                     INC (i); j := i;
  485.                     WHILE name[j] # 0X DO name[j-i] := name[j]; INC (j) END;
  486.                     name[j-i] := 0X; cmd := Modules.ThisCommand (mod, name);
  487.                     IF cmd # NIL THEN
  488.                         SYS.GET (SYS.ADR (cmd), pc);
  489.                         SYS.GET (SYS.ADR (cmd)+4, sb);
  490.                         lastpos := 0; RTDT.Install; RTDT.Prepare (pc, sb);
  491.                         RTDB.StepAll; HALT (RTDT.EnterDebugMode)
  492.                     ELSE
  493.                         Texts.WriteString (w, "Command not found: "); Texts.WriteString (w, name);
  494.                         Texts.WriteLn (w); Texts.Append (Oberon.Log, w.buf)
  495.                     END
  496.                 ELSE
  497.                     Texts.WriteString (w, "Module not found: "); Texts.WriteString (w, name);
  498.                     Texts.WriteLn (w); Texts.Append (Oberon.Log, w.buf)
  499.                 END
  500.             END
  501.         END
  502. END Start;
  503. Syntax10.Scn.Fnt
  504. BEGIN IF RTDT.Debugging () THEN RTDB.RestoreAll; RTDT.Stop; RTDC.Release END
  505. END Stop;
  506. MODULE Debug; (* Run time debugger: Commands; mah 25.10.94 (
  507. IMPORT    RTDB, RTDT, RTDC, RTDD, Modules, Texts, Oberon, SYS := SYSTEM, Sys, HandlerElems,
  508.             Viewers, MenuViewers, TextFrames, Display, Fonts, FoldElems, System,
  509. CONST
  510.     InfoMenu = "System.Close System.Grow Debug.Data Debug.Source ";       (* system track *)
  511.     PCElem = POINTER TO PCElemDesc;
  512.     BPElem = POINTER TO BPElemDesc;
  513.     PCElemDesc = RECORD (Texts.ElemDesc)
  514.     BPElemDesc = RECORD (Texts.ElemDesc)
  515.     SetPCMsg = RECORD (Display.FrameMsg)
  516.     UpdateDataMsg = RECORD (Display.FrameMsg) END;
  517.     Text = POINTER TO TextDesc;
  518.     TextDesc = RECORD (Texts.TextDesc)
  519.     w: Texts.Writer;
  520.     iconPC, iconBP: Display.Pattern;    (* x = 0, y = -curfnt.minY, w = 13, h = 9 *)
  521.     lastPos: LONGINT;                (* latest text position of PC *)
  522.     lastBeginPC: LONGINT;            (* start PC of latest procedure on stack *)
  523.     PrevFrameHandle, PrevDataHandle: Display.Handler;
  524.     latestRTDTprocs: RTDT.Proc;
  525. PROCEDURE Browse (f: TextFrames.Frame;  userTrack: BOOLEAN; handle: Display.Handler; title,menu: ARRAY OF CHAR);
  526. PROCEDURE SkipComment (VAR s: Texts.Scanner);
  527. PROCEDURE Token (VAR s: Texts.Scanner);
  528. PROCEDURE NextToken (t: Texts.Text; VAR pos: LONGINT);
  529. PROCEDURE GetDsr (f: Display.Frame; pos: LONGINT; fnt: Fonts.Font; VAR dsr: INTEGER);
  530. PROCEDURE Show (f: TextFrames.Frame; pos: LONGINT);
  531. PROCEDURE PCElemHandle (e: Texts.Elem; VAR msg: Texts.ElemMsg);
  532. PROCEDURE BPElemHandle (e: Texts.Elem; VAR msg: Texts.ElemMsg);
  533. PROCEDURE AllocPCElem (mod: Modules.Module; pc: LONGINT) : PCElem;
  534. PROCEDURE GetArg (VAR s: Texts.Scanner);
  535. PROCEDURE FrameHandle (f: Display.Frame; VAR msg: Display.FrameMsg);
  536. PROCEDURE DataHandle (f: Display.Frame; VAR msg: Display.FrameMsg);
  537. VAR t: Text; mod: Modules.Module; ok: BOOLEAN; p: RTDT.Proc; org: LONGINT;
  538. BEGIN
  539.     WITH f: TextFrames.Frame DO
  540.         WITH msg: UpdateDataMsg DO
  541.             IF f.text IS Text THEN
  542.                 t := f.text(Text);
  543.                 IF (t.modName[0] = '@') & (t.regs = NIL) THEN
  544.                     IF RTDT.procs # NIL THEN                    (* global scope *)
  545.                         mod := Modules.ThisMod (RTDT.procs.modName);
  546.                         RTDC.Symbols (RTDT.procs.modName, t.syms);
  547.                         t.base := mod.SB; 
  548.                         RTDD.GetScope (w, t, t.syms, t.base, 0)
  549.                     ELSE Texts.WriteString (w, "no debugged Module available") END
  550.                 ELSIF t.modName[0] = '@' THEN                                                        (* local scope *)
  551.                     IF RTDT.procs # NIL THEN 
  552.                         RTDD.GetLocalScope (w, t, RTDC.FindProc (RTDT.procs), RTDT.procs.regs, 0)
  553.                     ELSE Texts.WriteString (w, "no debugged Procedure available")
  554.                     END
  555.                 ELSIF t.regs = NIL THEN                                         (* global scope *)
  556.                     mod := Modules.ThisMod (t.modName);
  557.                     IF mod # NIL THEN
  558.                         t.base := mod.SB;
  559.                         RTDD.GetScope (w, t, t.syms, t.base, 0)
  560.                     ELSE Texts.WriteString (w, "Module not loadable")
  561.                     END
  562.                 ELSE                                                        (* local scope *)
  563.                     p := RTDT.procs;
  564.                     WHILE (p # NIL) & (p.regs # t.regs) DO p := p.up END;
  565.                     IF p # NIL THEN RTDD.GetLocalScope (w, t, t.syms, t.regs, 0)
  566.                     ELSE Texts.WriteString (w, "Old View")
  567.                     END
  568.                 END;
  569.                 org := f.org;
  570.                 Texts.Delete (t, 0, t.len);
  571.                 Texts.Append (t, w.buf);
  572.                 TextFrames.Show (f, org)
  573.             ELSE PrevDataHandle (f, msg) END
  574.         ELSE PrevDataHandle (f, msg) END
  575. END DataHandle;
  576. PROCEDURE WriteStackText;
  577. PROCEDURE StackHandle (f: Display.Frame; VAR msg: Display.FrameMsg);
  578. PROCEDURE PCHandler;
  579. PROCEDURE PCOffHandler;
  580. PROCEDURE NewText (syms: RTDC.Sym; base: LONGINT; regs: Sys.ExceptionInfo; VAR modName: ARRAY OF CHAR) : Text;
  581. PROCEDURE DataHandler;
  582. PROCEDURE StepInto*;
  583. PROCEDURE Step*;
  584. PROCEDURE Return*;
  585. PROCEDURE Run*;
  586. PROCEDURE PostMortem*;
  587. PROCEDURE Close*;
  588. PROCEDURE Trace*;
  589. PROCEDURE ShowModules*;
  590. PROCEDURE Stack*;
  591. PROCEDURE Source*;
  592. PROCEDURE Breakpoint*;
  593. PROCEDURE Data*;
  594. PROCEDURE Locals*;
  595. PROCEDURE Globals*;
  596. PROCEDURE InitIcon;
  597. BEGIN
  598. END Debug.
  599. PROCEDURE Start*;
  600. PROCEDURE Stop*;
  601.